/******************************************************************************/
//	KlinkTimer.h	-	Provides simple timing capabilities
//
//	Author:		Russell Klinkerman
//	Created:	09.02.2004
//
/******************************************************************************/

#ifndef _KLINKTIMER_H_
#define _KLINKTIMER_H_

#include <windows.h>
#pragma comment(lib, "winmm.lib")

class CKlinkTimer
{
	private:

		// Timer Variables

		static unsigned int	uiCurrentTime;	//	The current time
		static unsigned int	uiPreviousTime;	//	The time the previous frame.

		unsigned int		uiStartTime;	//	The time this timer began
		unsigned int		uiEndTime;		//	The time this timer should trigger.

	public:

		// default constructor
		CKlinkTimer();

		// constructor
		CKlinkTimer(unsigned int _uiEndTime);

		// destructor
		~CKlinkTimer();

		/******************************************************************************/
		//	Update	-	Update current and previous time members (Once per frame)
		/******************************************************************************/
		static void	Update();

		/******************************************************************************/
		//	Set	-	Sets a timer to trigger at a certain point in time.
		//
		//	In:		_uiEndTime	-	The time (in milliseconds) this timer will trigger
		/******************************************************************************/
		void	Set(unsigned int _uiEndTime);

		/******************************************************************************/
		//	Check	-	Checks if it is time for a timer to trigger
		//
		//	Return:	TRUE if successful
		/******************************************************************************/
		bool	Check();

		/******************************************************************************/
		// GetSecondsSincePrevious	-	Return the number of seconds that have passed
		//								since previous update.
		/******************************************************************************/
		static inline float	GetSecondsSincePrevious()
		{	
			return float(uiCurrentTime - uiPreviousTime) / 1000.0f;
		}

};


#endif